package org.syntaxlisp.core.element;

import lombok.Getter;

import java.util.Optional;

/**
 * @author HuangYijun
 * @data 2023-02-03 09:57
 **/
public enum  ReservedTag {

    ZERO_OR_MORE("*"),
    ZERO_OR_ONE("+"),
    ONE_OR_MORE("~"),

    ZERO_OR_MORE_GREEDY("**"),
    ZERO_OR_ONE_GREEDY("+*"),
    ONE_OR_MORE_GREEDY("~*"),

    SEQ_CONNECT("&"),
    DEFINITION("DEF"),
    DEFINITION_INCLUSIVE("DEFIN"),

    REPEAT("RPT"),
    REPEAT_GREEDY("RPT_GDY"),

    UNICODE_CHARACTER_SCOPE("UNICODE"),

    NOT_IN("!"),
    NOT_OR("NOR"),
    ALTERNATIVE("OR"),
    SCOPE("-"),
    UNICODE_CHARACTER("UNI"),
    INFINITY("INF"),
    IMPORT("IMP"),
    HUNGER("HGR"),

    LOOK_AHEAD_EXCLUDE("LAE"),

    MATCH_BUT_IGNORE("MBI"),

    DEFINITION_STRING("DEF_STR");

    @Getter
    private final String tag;

    ReservedTag(String tag) {
        this.tag = tag;
    }

    public static boolean isReservedTag(String value) {
        for (ReservedTag word : values()) {
            if (word.tag.equals(value)) {
                return true;
            }
        }
        return false;
    }

    public static Optional<ReservedTag> matches (String tag) {
        for (ReservedTag word : values()) {
            if (word.tag.equals(tag)) {
                return Optional.of(word);
            }
        }
        return Optional.empty();
    }

    public boolean isMatch (String targetTag) {
        return tag.equals(targetTag);
    }
}
